/**
 * 登录
 */
function sendLogin() {
    var form = $("#login-form");
    var params = {};
    var validFlag = true;
    $.each(form.find('input'), function (i, v) {
        if (v.name != "") {
            var val = v.value;
            if (!val) {
                $(v).focus();
                setNotify($(v).attr('data-error'), true);

                validFlag = false;
                return false;
            }

            params[v.name] = v.value;
        }
    });
    if (!validFlag) return false;
    $.post("/default/submit", params, function (json) {
        if (json.code == 1) {
            //判断是否有
            // UrlPara=getCookie('UrlPara');
            // if (UrlPara) {
            //     //删除cookie
            //     delCookie('UrlPara');
            //     window.location.href = '/admin/'+UrlPara;
            // } else {
                window.location.href = "/admin/index";
            // }
        } else {
            refreshCaptcha(2);
            layer.msg(json.msg);
        }
    }, 'json');
}
//js 获取cookie
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}
//js 删除cookie
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
/*
* 登陆跳转
* */
window.onload=function(){
    var curPath=window.document.location.href;
    var url = document.location.toString();
    var arrUrl = url.split("#");
    if (arrUrl[1]) {
        document.cookie="UrlPara="+arrUrl[1];
    }

}



